# -*- coding:utf-8 -*-
"""
元组比字典占用内存更少，可以利用元组存储信息
但是使用索引访问元组元素，降低了程序可读性
"""
student = ('Jim', 16, 'male', 'jim@qq.com')
# 方法1
Name, Age, Sex, Email = range(4)
print(student[Name])
# 方法2：使用枚举
from enum import IntEnum


class Student(IntEnum):
    Name = 0
    Age = 1
    Sex = 2
    Email = 3


print(student[Student.Name])
# 方法3：为元组元素起名字
from collections import namedtuple

Student = namedtuple('student', ['Name', 'Age', 'Sex', 'Email'])  # 定义元组各个元素的名称
student = Student('Jim', 16, 'male', 'jim@qq.com')
print(student[0])  # 因为student属于tuple对象
print(student.Name)
